package com.tac.controller;

import com.tac.common.result.Result;
import com.tac.pojo.Slide;
import com.tac.service.SlideService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/slide")
@RestController
@CrossOrigin
@Api(value = "轮播图",tags ="轮播图" )
public class SlideController {
    @Autowired
    private SlideService slideService;
    /**
     * 添加轮播图
     * @param file
     * @return
     */
    @ResponseStatus(HttpStatus.CREATED)
    @PostMapping()
    @ApiOperation("添加轮播图")
    public Result save(String file){
       return slideService.save(file);
    }
    /**
     * 删除轮播图
     * @param id
     * @return
     */
    @ResponseStatus(HttpStatus.NO_CONTENT)
    @ApiOperation("删除轮播图")
    @DeleteMapping("/{id}")

    public Result remove(@PathVariable Integer id){
        return slideService.remove(id);
    }

    /**
     * 查看轮播图
     * @return
     */
    @ApiOperation("查看轮播图")
    @GetMapping
    public Result<List<Slide>> selectAll(){
        return slideService.selectAll();
    }

}
